/* eslint-disable react/no-danger */
/* eslint-disable array-callback-return */
import React from 'react';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import {
  Card,
  Button,
  Spin,
  Anchor,
  Row,
  Col,
  Table,
  Timeline,
  Modal,
  Steps,
  Badge,
  Popover,
  Divider,
  message,
  DatePicker,
  Input,
} from 'antd';
import { connect } from 'dva';
import router from 'umi/router';
import moment from 'moment';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import FooterToolbar from '@/components/FooterToolbar';
import DescriptionList from '@/components/DescriptionList';
import downloadFile, { getFileName } from '@/utils/utils';

const FormItem = Form.Item;
const { Step } = Steps;
const { Description } = DescriptionList;
const { MonthPicker } = DatePicker;
const { Link } = Anchor;

@connect(({ addempdetailreceive, loading }) => ({
  loading: loading.effects['addempdetailreceive/fetchReturnDetail'],
  modalLoading: loading.effects['addempdetailreceive/fetchPayDetail'],
  addempdetailreceive,
  insFlag: addempdetailreceive.insFlag,
}))
@Form.create()
class BasicForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      recvOrdAddTaskId: null,
      modalVisible: false,
      switchFlag: true,
      modalVisibles: false, // 修改弹框显是隐藏
      timeStart: '',
      recvOrdSetId: '',
      recvOrdPdId: '',
      currentDate: '',
    };
  }

  componentDidMount() {
    const {
      dispatch,
      location: { query },
    } = this.props;
    // 获取取消回单详情信息
    dispatch({
      type: 'addempdetailreceive/fetchReturnDetail',
      payload: query,
    });
    dispatch({
      type: 'addempdetailreceive/controlNavnum',
      payload: {},
    });
    this.setState({ recvOrdAddTaskId: query.recvOrdAddTaskId });
  }

  componentWillUnmount() {
    const { dispatch } = this.props;
    const resetInfo = {
      recvOrdAddTaskId: null,
      sendOrdDetailDto: null, // 派单信息
      pdInfoDtos: null, // 产品服务信息
      protInfoDto: null, // 协议信息
      setInfos: null, // 险种
      addEmpDetSerDto: null, // 社保公积金信息
      handDto: null, // 办理备注
      assDetailDtoList: null, // 增加险种信息
      execStatusDto: null, // 执行状态
      dataDtos: null, // 材料信息
      contRecDtoList: null, // 联系记录
      payDetailList: [], // 明细详情
    };
    dispatch({
      type: 'addempdetailreceive/updateModelData',
      payload: { ...resetInfo },
    });
  }

  // 材料信息（来自员工系统）
  getVal = value => {
    if (value.inpVal) {
      if (value.inpType && value.inpType === 9 && value.inpVal !== '[]') {
        return this.addLink(value.inpVal);
      }
      if (value.inpType && value.inpType === 9 && value.inpVal === '[]') {
        return '--';
      }
      return this.commanName(value);
    }
    return '--';
  };

  commanName = item => (item.inpVal ? item.inpVal : '--');

  addLink = matinfo =>
    matinfo.split(',').map(item => {
      const matinfoItem = item.split('|')[1];
      const matinfoName = getFileName(matinfoItem);
      return (
        <span key={item}>
          <a onClick={() => this.downLoad(item)}>{matinfoName}</a>
        </span>
      );
    });

  downLoad = item => {
    const file = item.split('|');
    downloadFile({ fileId: file[0], fileName: getFileName(file[1]) });
  };

  // 获取缴纳明细弹框
  getPayDetail = () => {
    const { dispatch } = this.props;
    const { recvOrdAddTaskId } = this.state;
    dispatch({
      type: 'addempdetailreceive/fetchPayDetail',
      payload: { recvOrdAddTaskId },
    });
    this.setState({
      modalVisible: true,
    });
  };

  // 切换模态框：新增、修改
  handleModalVisible = flag => {
    this.setState({
      modalVisible: !!flag,
      modalVisibles: !!flag,
    });
  };

  // 分项设置
  subsett = () => {
    const {
      addempdetailreceive: { pdInfoDtos, setInfos },
      dispatch,
    } = this.props;
    const { switchFlag } = this.state;
    const newsetInfosList = setInfos.filter(item => item.ass !== 2); // 过滤公积金的数据
    const dataList = JSON.parse(JSON.stringify(pdInfoDtos));
    if (switchFlag) {
      let i = 0;
      dataList.forEach((item, index) => {
        if (item.pdId === 'PDINF_0000000001') {
          i = index;
          newsetInfosList.map(item1 => {
            const temp = item1;
            temp.pdName = temp.assName;
            temp.sendBeginDate = temp.sendBeginDate;
            temp.cityName = temp.cityName;
          });
          dataList.splice(i + 1, 0, ...newsetInfosList);
        }
      });
      this.setState({ switchFlag: false });
      dispatch({
        type: 'addempdetailreceive/updateModalData',
        payload: { 
          pdInfoDtos: dataList,
        },
      });
    } else {
      let i = 0;
      dataList.forEach((item, index) => {
        if (item.pdId === 'PDINF_0000000001') {
          i = index;
          dataList.splice(i + 1, setInfos.length); // 将五险的数据截取掉
        }
      });
      this.setState({ switchFlag: true });
      dispatch({
        type: 'addempdetailreceive/updateModalData',
        payload: { 
          pdInfoDtos: dataList,
        },
      });
    }
  };

  // 取消回单
  cancelReceipt = record => {
    const { dispatch } = this.props;
    const receArr = [];
    const { recvOrdAddTaskId } = this.state;
    receArr.push(recvOrdAddTaskId);
    dispatch({
      type: 'addempdetailreceive/cancelReturnReceipt',
      payload: record.ass
        ? { ass: record.ass, recvOrdAddTaskId: receArr }
        : { pdId: record.pdId, recvOrdAddTaskId: receArr },
      callback: response => {
        if (response.success) {
          message.success('取消回单成功！');
          dispatch({
            type: 'addempdetailreceive/fetchReturnDetail',
            payload: {
              recvOrdAddTaskId,
            },
          });
          this.setState({ switchFlag: true });
        } else {
          message.warning(response.message || '服务器端错误');
        }
      },
    });
  };

  // 修改
  update = record => {
    const { form } = this.props;
    form.resetFields();
    // form.setFieldsValue({ product: record.editDesc });
    this.setState({
      modalVisibles: true,
      timeStart: record.sendBeginDate,
      recvOrdSetId: record.recvOrdAddSetId ? record.recvOrdAddSetId : '',
      recvOrdPdId: record.recvOrdAddPdId ? record.recvOrdAddPdId : '',
    });
  };

  // 修改时间
  changetime = e => {
    const currentDate = moment(e).format('YYYY-MM-01');
    this.setState({
      currentDate,
    });
  };

  // 回单
  receipt = record => {
    const { dispatch } = this.props;
    const { recvOrdAddTaskId } = this.state;
    dispatch({
      type: 'addempreceiptrec/receiptId',
      payload: record.ass
        ? { ass: record.ass, recvOrdAddTaskId }
        : { pdId: record.pdId, recvOrdAddTaskId },
      callback: response => {
        if (response.success) {
          message.success('回单成功！');
          this.setState({ switchFlag: true });
          dispatch({
            type: 'addempdetailreceive/fetchReturnDetail',
            payload: { recvOrdAddTaskId },
          });
        } else {
          message.warning(response.message || '回单失败!');
        }
      },
    });
  };

  // 修改提交
  submitData = () => {
    const { dispatch, form } = this.props;
    const { recvOrdAddTaskId, recvOrdPdId, recvOrdSetId } = this.state;
    const getFieldsList = form.getFieldsValue();
    form.validateFields(['bigenTime', 'product'], err => {
      if (!err) {
        const times = getFieldsList.bigenTime ? getFieldsList.bigenTime.format('YYYYMM01') : null;
        let paramet = {};
        if (recvOrdPdId.length > 0) {
          paramet = {
            recvBeginYm: times,
            remark: getFieldsList.product,
            recvOrdTaskId: recvOrdAddTaskId,
            recvOrdPdId,
          };
        } else {
          paramet = {
            recvBeginYm: times,
            remark: getFieldsList.product,
            recvOrdTaskId: recvOrdAddTaskId,
            recvOrdSetId,
          };
        }
        dispatch({
          type: 'addempreceiptrec/modification',
          payload: paramet,
          callback: response => {
            if (response.success) {
              message.success('修改成功！');
              this.handleModalVisible(false);
              this.setState(
                {
                  switchFlag: true,
                },
                () => {
                  dispatch({
                    type: 'addempdetailreceive/fetchReturnDetail',
                    payload: { recvOrdAddTaskId },
                  });
                }
              );
            } else {
              message.warning(response.message || '修改失败!');
              this.handleModalVisible(false);
            }
          },
        });
      }
    });
  };

  render() {
    const {
      loading,
      addempdetailreceive: {
        sendOrdDetailDto, // 派单信息
        pdInfoDtos, // 产品服务信息
        setInfos, // 险种
        protInfoDto, // 协议信息
        addEmpDetSerDto, // 社保公积金信息
        assDetailDtoList, // 增加险种信息
        execStatusDto, // 执行状态
        dataDtos, // 材料信息
        contRecDtoList, // 联系记录
        handDto, // 办理备注
        payDetailList, // 缴费明细
        navNum, // 导航数量
        coltFlag = 1, // 是否需要材料信息
      },
      form: { getFieldDecorator },
      modalLoading,
      insFlag,
    } = this.props;
    const { modalVisible, modalVisibles, currentDate, switchFlag, timeStart } = this.state;
    const protInfoDtoList = (protInfoDto && [{ ...protInfoDto }]) || [];
    const formItemLayout = {
      labelCol: { span: 6 },
      wrapperCol: { span: 14 },
    };
    const formItemLayouts = {
      labelCol: { span: 8 },
      wrapperCol: { span: 14 },
    };

    // 产品服务信息
    const pdColumns = [
      {
        title: '产品',
        dataIndex: 'pdName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
      },
      {
        title: '执行地',
        dataIndex: 'cityName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
      },
      {
        title: '业务开始日期',
        dataIndex: 'sendBeginDate',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: sendBeginDate =>
          (sendBeginDate && moment(sendBeginDate).format('YYYY-MM-01')) || '--',
      },
      {
        title: '操作',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: (text, record) => (
          <div>
            {record.pdId === 'PDINF_0000000001' ? (
              <span>
                {insFlag === 1 ? (
                  <span>
                    <a
                      style={{ marginRight: '10px' }}
                      onClick={() => {
                        this.receipt(record);
                      }}
                    >
                      回单
                    </a>
                    <a
                      onClick={() => {
                        this.update(record);
                      }}
                    >
                      修改
                    </a>
                  </span>
                ) : null}

                {record.receFlag === 1 ? (
                  <span>
                    {switchFlag ? (
                      <a
                        style={{ marginRight: 16 }}
                        onClick={() => this.cancelReceipt(text, record)}
                      >
                        取消回单
                      </a>
                    ) : null}
                  </span>
                ) : null}
                {switchFlag ? (
                  <span>
                    {setInfos && setInfos.length === 0 && record.receFlag === 2 ? null : (
                      <a
                        style={{ marginLeft: 16 }}
                        onClick={() => {
                          this.subsett(record);
                        }}
                      >
                        分项设置
                      </a>
                    )}
                  </span>
                ) : (
                  <a
                    style={{ marginLeft: 16 }}
                    onClick={() => {
                      this.subsett(record);
                    }}
                  >
                    取消分项设置
                  </a>
                )}
              </span>
            ) : (
              <div>
                {record.pdId === 'PDINF_0000000002' ? (
                  <span>
                    {record.receFlag === 2 ? (
                      <a
                        style={{ marginRight: '10px' }}
                        onClick={() => {
                          this.receipt(record);
                        }}
                      >
                        回单
                      </a>
                    ) : null}

                    {record.receFlag === 1 ? (
                      <a
                        style={{ marginRight: '10px' }}
                        onClick={() => this.cancelReceipt(text, record)}
                      >
                        取消回单
                      </a>
                    ) : (
                      <a
                        onClick={() => {
                          this.update(record);
                        }}
                      >
                        修改
                      </a>
                    )}
                  </span>
                ) : (
                  record &&
                  record.ass && (
                    <span>
                      {!switchFlag && record.receFlag === 1 ? (
                        <a onClick={() => this.cancelReceipt(text, record)}>取消回单</a>
                      ) : null}
                      {!switchFlag && record.receFlag === 2 ? (
                        <a
                          style={{ marginRight: '10px' }}
                          onClick={() => {
                            this.receipt(record);
                          }}
                        >
                          回单
                        </a>
                      ) : null}
                      {record.receFlag === 2 ? (
                        <a
                          onClick={() => {
                            this.update(record);
                          }}
                        >
                          修改
                        </a>
                      ) : null}
                    </span>
                  )
                )}
              </div>
            )}
          </div>
        ),
      },
    ];
    // 协议信息
    const protColumns = [
      {
        title: '协议名称',
        dataIndex: 'suppProtName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
      },
      {
        title: '接单方',
        dataIndex: 'sendSuppName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
      },
      {
        title: '服务产品',
        dataIndex: 'pdName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
      },
      {
        title: '执行地',
        dataIndex: 'areaName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
      },
      {
        title: '价格',
        dataIndex: 'price',
        align: 'right',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => (val && val.toFixed(2)) || '--',
      },
    ];
    // 社保公积金信息
    const insAccuColumns = [
      {
        title: '险种',
        dataIndex: 'assName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '缴费方式',
        dataIndex: 'payWayName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '缴费账户',
        dataIndex: 'accoName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '申报工资',
        dataIndex: 'decWage',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => (val && parseFloat(val).toFixed(2)) || '--',
      },
      {
        title: '政策组合',
        dataIndex: 'grpName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
    ];
    // 增加险种信息
    const addassColumns = [
      {
        title: '产品',
        dataIndex: 'assName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '执行地',
        dataIndex: 'areaName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '缴费方式',
        dataIndex: 'payWayName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '缴纳账户',
        dataIndex: 'accoPlcyName',
        align: 'center',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '申报工资',
        dataIndex: 'decWage',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '社保组合',
        dataIndex: 'grpName',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '业务开始日期',
        dataIndex: 'begTime',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: begTime => (begTime && moment(begTime).format('YYYY-MM-01')) || '--',
      },
      {
        title: '操作',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: (text, record) => (
          <a style={{ marginRight: 16 }} onClick={() => this.cancelReceipt(text, record)}>
            取消回单
          </a>
        ),
      },
    ];
    // 缴纳明细
    const payDetailColumns = [
      {
        title: '产品名称',
        dataIndex: 'assName',
        align: 'center',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
      {
        title: '业务开始日期',
        dataIndex: 'beginDate',
        align: 'center',
        sorter: (a, b) => new Date(b.beginDate) - new Date(a.beginDate),
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => (val && moment(val).format('YYYY-MM-01')) || '--',
      },
      {
        title: '业务结束日期',
        dataIndex: 'endDate',
        align: 'center',
        sorter: (a, b) => new Date(b.endDate) - new Date(a.endDate),
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => {
          if (val && val && moment(val).format('YYYY-MM-01')) {
            const start = val && moment(val).format('YYYY-MM-01');
            const end = moment(start)
              .add('month', 1)
              .add('days', -1)
              .format('YYYY-MM-DD');
            return end;
          }
          return '无';
        },
      },
      {
        title: '缴纳金额',
        dataIndex: 'payAmount',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'right' } }),
        render: val => val || (val === 0 ? 0 : null),
      },
      {
        title: '企业基数',
        dataIndex: 'entpBase',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'right' } }),
        render: val => (val ? val.toFixed(2) : null),
      },
      {
        title: '企业比例(%)',
        dataIndex: 'entpProp',
        align: 'center',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || (val === 0 ? 0 : null),
      },
      {
        title: '企业附加(元)',
        dataIndex: 'entpAddnAmo',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'right' } }),
        render: val => val || (val === 0 ? 0 : null),
      },
      {
        title: '企业缴费',
        dataIndex: 'entpPay',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'right' } }),
        render: val => val || (val === 0 ? 0 : null),
      },
      {
        title: '个人基数',
        dataIndex: 'perBase',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'right' } }),
        render: val => val || (val === 0 ? 0 : null),
      },
      {
        title: '个人比例(%)',
        dataIndex: 'perProp',
        align: 'center',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || (val === 0 ? 0 : null),
      },
      {
        title: '个人附加(元)',
        dataIndex: 'perAddnAmo',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'right' } }),
        render: val => val || (val === 0 ? 0 : null),
      },
      {
        title: '个人缴费',
        dataIndex: 'perPay',
        onHeaderCell: () => ({ style: { fontWeight: 'bold', textAlign: 'center' } }),
        onCell: () => ({ style: { textAlign: 'right' } }),
        render: val => val || (val === 0 ? 0 : null),
      },
      {
        title: '执行地区',
        dataIndex: 'cityName',
        align: 'center',
        onHeaderCell: () => ({ style: { fontWeight: 'bold' } }),
        render: val => val || '--',
      },
    ];

    const customDot = (dot, { status }) =>
      status === 'process' ? (
        <Popover placement="topLeft" arrowPointAtCenter>
          {dot}
        </Popover>
      ) : (
        dot
      );

    // 判断是否为空对象
    const isEmptyObj = obj => {
      if (obj) {
        return JSON.stringify(obj) === '{}';
      }
      return false;
    };

    const status1 = (item, leafDet) => {
      if (item.operLeafType === 4) {
        return leafDet.doneFlag === 3 ? 'success' : 'default';
      }
      return leafDet.doneFlag === 1 ? 'success' : 'default';
    };
    // 是否含有材料信息
    const isShowMat = () => {
      if (coltFlag) {
        if (String(coltFlag) === '1') {
          return dataDtos && dataDtos.length ? (
            <DescriptionList style={{ marginBottom: '20px' }}>
              {dataDtos.map(item => (
                <Description
                  key={item.matName}
                  term={item.matName}
                  style={{ wordBreak: 'break-all' }}
                >
                  {this.getVal(item)}
                </Description>
              ))}
            </DescriptionList>
          ) : (
            '暂无数据'
          );
        }
        return (
          <DescriptionList style={{ marginBottom: '20px' }}>
            <Description term="材料是否完整">不需要材料</Description>
          </DescriptionList>
        );
      }
      return true;
    };

    return (
      <Form>
        <PageHeaderWrapper>
          <Spin tip="Loading..." spinning={loading}>
            {navNum > '4' ? (
              <Anchor onClick={e => e.preventDefault()} targetOffset={50}>
                <Row
                  style={{ padding: '15px 0', fontWeight: 'bold' }}
                  type="flex"
                  justify="space-between"
                >
                  {sendOrdDetailDto && (
                    <Col>
                      <Link href="#sendinfo" title="派单信息" />
                    </Col>
                  )}
                  {sendOrdDetailDto && (
                    <Col>
                      <Link href="#basicinfo" title="员工信息" />
                    </Col>
                  )}
                  {pdInfoDtos && (
                    <Col>
                      <Link href="#pdinfo" title="产品服务信息" />
                    </Col>
                  )}
                  {protInfoDto && (
                    <Col>
                      <Link href="#protinfo" title="协议信息" />
                    </Col>
                  )}
                  {addEmpDetSerDto && (
                    <Col>
                      <Link href="#insaccuinfo" title="社保公积金信息" />
                    </Col>
                  )}
                  {assDetailDtoList && (
                    <Col>
                      <Link href="#addassinfo" title="增加险种信息" />
                    </Col>
                  )}
                  {execStatusDto && (
                    <Col>
                      <Link href="#runstatusinfo" title="执行状态" />
                    </Col>
                  )}
                  <Col>
                    <Link href="#materialinfo" title="材料信息" />
                  </Col>
                  {contRecDtoList && (
                    <Col>
                      <Link href="#contrecordinfo" title="联系记录" />
                    </Col>
                  )}
                  {handDto && (
                    <Col>
                      <Link href="#remarkinfo" title="办理备注" />
                    </Col>
                  )}
                </Row>
              </Anchor>
            ) : null}
            {/* 派单信息 */}
            {sendOrdDetailDto && (
              <Card
                title={<span style={{ fontWeight: 'bolder' }}>派单信息</span>}
                style={{ border: 'none', marginBottom: 16 }}
                id="sendinfo"
              >
                {(!isEmptyObj(sendOrdDetailDto) && (
                  <DescriptionList>
                    <Description term="签约方">{sendOrdDetailDto.sendSuppName || '--'}</Description>
                    <Description term="客户名称">{sendOrdDetailDto.custName || '--'}</Description>
                    <Description term="入职日期">
                      {(sendOrdDetailDto.entryDate &&
                        moment(sendOrdDetailDto.entryDate).format('YYYY-MM-DD')) ||
                        '--'}
                    </Description>
                    <Description term="是否入职联系">
                      {sendOrdDetailDto.conEmpFlagName || '--'}
                    </Description>
                    <Description term="操作人">{sendOrdDetailDto.sendRespName || '--'}</Description>
                    {sendOrdDetailDto.sendDate && (
                      <Description term="发单时间">
                        {(sendOrdDetailDto.sendDate &&
                          moment(sendOrdDetailDto.sendDate).format('YYYY-MM-DD HH:mm')) ||
                          '--'}
                      </Description>
                    )}
                  </DescriptionList>
                )) ||
                  '暂无数据'}
              </Card>
            )}

            {/* 员工信息 */}
            {sendOrdDetailDto && (
              <Card
                title={<span style={{ fontWeight: 'bolder' }}>员工信息</span>}
                style={{ border: 'none', marginBottom: 16 }}
                id="basicinfo"
              >
                {(!isEmptyObj(sendOrdDetailDto) && (
                  <DescriptionList>
                    <Description term="姓名">{sendOrdDetailDto.empName || '--'}</Description>
                    <Description term="证件类型">{sendOrdDetailDto.idTypeName || '--'}</Description>
                    <Description term="证件号">{sendOrdDetailDto.idCode || '--'}</Description>
                    <Description term="国籍">{sendOrdDetailDto.nationName || '--'}</Description>
                    <Description term="出生日期">
                      {(sendOrdDetailDto.birthDate &&
                        moment(sendOrdDetailDto.birthDate).format('YYYY-MM-DD')) ||
                        '--'}
                    </Description>
                    <Description term="性别">{sendOrdDetailDto.genderName || '--'}</Description>
                    <Description term="电话">{sendOrdDetailDto.mobile || '--'}</Description>
                    <Description term="员工邮箱">{sendOrdDetailDto.email || '--'}</Description>
                  </DescriptionList>
                )) ||
                  '暂无数据'}
              </Card>
            )}

            {/* 产品服务信息 */}
            {pdInfoDtos && (
              <Card
                title={<span style={{ fontWeight: 'bolder' }}>产品服务信息</span>}
                style={{ border: 'none', marginBottom: 16 }}
                id="pdinfo"
              >
                {(pdInfoDtos.length && (
                  <Table
                    dataSource={pdInfoDtos || []}
                    columns={pdColumns}
                    rowKey={(_, index) => index}
                    pagination={false}
                    style={{ maxWidth: 800 }}
                  />
                )) ||
                  '暂无数据'}
              </Card>
            )}

            {/* 协议信息 */}
            {protInfoDto && (
              <Card
                title={<span style={{ fontWeight: 'bolder' }}>协议信息</span>}
                style={{ border: 'none', marginBottom: 16 }}
                id="protinfo"
              >
                {(protInfoDtoList.length && (
                  <Table
                    dataSource={protInfoDtoList || []}
                    columns={protColumns}
                    rowKey={(_, index) => index}
                    pagination={false}
                  />
                )) ||
                  '暂无数据'}
              </Card>
            )}

            {/* 社保公积金信息 */}
            {addEmpDetSerDto && (
              <Card
                title={
                  <div style={{ position: 'relative' }}>
                    <span style={{ fontWeight: 900 }}>社保公积金信息</span>
                    <a
                      onClick={this.getPayDetail}
                      style={{ position: 'absolute', top: '0', right: '0', fontSize: '14px' }}
                    >
                      缴纳明细
                    </a>
                  </div>
                }
                style={{ border: 'none', marginBottom: 16 }}
                id="insaccuinfo"
              >
                {(!isEmptyObj(addEmpDetSerDto) && (
                  <Table
                    dataSource={addEmpDetSerDto.detailSerDtos || []}
                    columns={insAccuColumns}
                    rowKey={(_, index) => index}
                    pagination={false}
                  />
                )) ||
                  '暂无数据'}
              </Card>
            )}

            {/* 增加险种信息 */}
            {assDetailDtoList && (
              <Card
                title={<span style={{ fontWeight: 'bolder' }}>增加险种信息</span>}
                style={{ border: 'none', marginBottom: 16 }}
                id="addassinfo"
              >
                {(assDetailDtoList.length && (
                  <Table
                    dataSource={assDetailDtoList || []}
                    columns={addassColumns}
                    rowKey={(_, index) => index}
                    pagination={false}
                  />
                )) ||
                  '暂无数据'}
              </Card>
            )}

            {/* 执行状态 */}
            {execStatusDto && (
              <Card
                title={<span style={{ fontWeight: 'bolder' }}>执行状态</span>}
                style={{ border: 'none', marginBottom: 16 }}
                id="runstatusinfo"
              >
                {(execStatusDto.leafList && execStatusDto.leafList.length && (
                  <Steps
                    progressDot={customDot}
                    style={{ width: '60%', margin: '0 auto', marginTop: 20 }}
                  >
                    {execStatusDto &&
                      execStatusDto.leafList.map(item => (
                        <Step
                          key={item.operLeafTypeName}
                          title={item.operLeafTypeName}
                          description={
                            !item.leafDetList.length ? (
                              `暂无${item.operLeafType === '3' ? '办理' : '申报'}内容`
                            ) : (
                              <div style={{ width: 400, fontSize: 12, textAlign: 'left' }}>
                                {item.leafDetList.map(leafDet => (
                                  <div key={leafDet.leafDetId}>
                                    <Badge
                                      status={status1(item, leafDet)}
                                      text={
                                        <span style={{ lineHeight: '30px' }}>
                                          {leafDet.leafDetTypeName}&nbsp;
                                          <span style={{ color: '#999' }}>
                                            {leafDet.cityName ? `(${leafDet.cityName})` : ''}
                                          </span>
                                          &nbsp;:{leafDet.doneFlagName || '--'}
                                          <span
                                            style={{
                                              fontSize: '12px',
                                              color: '#999',
                                              marginLeft: 15,
                                            }}
                                          >
                                            {leafDet.operTime &&
                                              moment(leafDet.operTime).format('YYYY-MM-DD')}
                                          </span>
                                        </span>
                                      }
                                    />
                                    <br />
                                  </div>
                                ))}
                              </div>
                            )
                          }
                          status={item.doneFlag === 1 ? 'finish' : 'wait'}
                        />
                      ))}
                  </Steps>
                )) ||
                  '暂无数据'}
              </Card>
            )}

            {/* 材料信息 */}
            <Card
              title={<span style={{ fontWeight: 'bolder' }}>材料信息</span>}
              style={{ border: 'none', marginBottom: 16 }}
              id="materialinfo"
            >
              {isShowMat()}
            </Card>

            {/* 联系记录 */}
            {contRecDtoList && (
              <Card
                title={<span style={{ fontWeight: 'bolder' }}>联系记录</span>}
                style={{ border: 'none', marginBottom: 16 }}
                id="contrecordinfo"
              >
                {(contRecDtoList.length &&
                  contRecDtoList.map((item, index) => (
                    <div>
                      {index > 0 && <Divider dashed />}
                      <DescriptionList>
                        <Description term="联系方式">{item.contactInfo || '--'}</Description>
                        {item.contactInfo === '短信' || item.contactInfo === '电话' ? (
                          <Description term="联系电话">{item.contactMobile}</Description>
                        ) : (
                          <Description term="邮件">{item.email || '--'}</Description>
                        )}
                        <Description term="联系人">{item.contactPer || '--'}</Description>
                        <Description term="联系时间">{item.contactTime || '--'}</Description>
                        <Description term="联系内容">
                          <span dangerouslySetInnerHTML={{ __html: item.remark || '--' }} />
                        </Description>
                      </DescriptionList>
                    </div>
                  ))) ||
                  '暂无数据'}
              </Card>
            )}

            {/* 办理备注 */}
            {handDto && (
              <Card
                title={<span style={{ fontWeight: 'bolder' }}>办理备注</span>}
                style={{ border: 'none', marginBottom: 16 }}
                id="remarkinfo"
              >
                {(handDto.length && (
                  <Timeline>
                    {handDto.map(item => (
                      <Timeline.Item>
                        <p style={{ float: 'left', margin: '0 15px 0 20px' }}>
                          {item.operTime && moment(item.operTime).format('YYYY-MM-DD HH:mm')}
                        </p>
                        <p style={{ float: 'left', margin: '0 20px 0 15px' }}> {item.operName} </p>
                        <p> {item.content} </p>
                      </Timeline.Item>
                    ))}
                  </Timeline>
                )) ||
                  '暂无数据'}
              </Card>
            )}
            <Modal
              width={1200}
              visible={modalVisible}
              onCancel={() => this.handleModalVisible(false)}
              title="社保公积金明细"
              footer={[
                <Button
                  key="submit"
                  type="primary"
                  loading={loading}
                  onClick={() => this.handleModalVisible(false)}
                >
                  关闭
                </Button>,
              ]}
            >
              <Table
                dataSource={payDetailList}
                columns={payDetailColumns}
                rowKey={(_, index) => index}
                loading={modalLoading}
                pagination={false}
              />
            </Modal>
            <FooterToolbar style={{ width: '100%' }}>
              <Button onClick={() => router.goBack()}>返回</Button>
            </FooterToolbar>
          </Spin>

          <Modal
            width={800}
            title="修改"
            visible={modalVisibles}
            okText="确定"
            cancelText="取消"
            onOk={this.submitData}
            onCancel={() => this.handleModalVisible(false)}
          >
            <Form>
              <div style={{ float: 'left', width: '350px' }}>
                <p style={{ lineHeight: '1px' }}>
                  签约方：
                  {sendOrdDetailDto && sendOrdDetailDto.sendSuppName
                    ? sendOrdDetailDto.sendSuppName
                    : null}
                </p>
                <p style={{ margin: '45px 0 0 0' }}>
                  业务开始日期：{moment(timeStart).format('YYYY-MM-01')}
                </p>
              </div>
              <div style={{ float: 'left', width: '350px' }}>
                <p style={{ lineHeight: '1px', margin: '0 0 40px 0' }}>
                  接单方：
                  {sendOrdDetailDto && sendOrdDetailDto.recvSuppName
                    ? sendOrdDetailDto.recvSuppName
                    : null}
                </p>
                <FormItem {...formItemLayouts} label="业务开始日期">
                  {getFieldDecorator('bigenTime', {
                    rules: [{ required: true, message: '请选择' }],
                  })(<MonthPicker onChange={e => this.changetime(e)} format={currentDate} />)}
                </FormItem>
                <FormItem {...formItemLayout} label="变更说明">
                  {getFieldDecorator('product', {
                    rules: [{ required: true, message: '请输入' }],
                  })(<Input placeholder="请输入" maxLength={100} />)}
                </FormItem>
              </div>
            </Form>
          </Modal>
        </PageHeaderWrapper>
      </Form>
    );
  }
}

const BasicFormList = Form.create()(BasicForm);
export default BasicFormList;
